package com.google.antranking.utils;

import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.widget.Toast;

public class Log {


	private static String getTag() {
		StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace();
		String fullClassName = stackTraceElements[4].getClassName();
		String className = fullClassName.substring(fullClassName.lastIndexOf(".") + 1);
		int lineNumber = stackTraceElements[4].getLineNumber();
		return "asl." + className + ":" + lineNumber;
	}

	private static void toast(Context context, String message) {
		Toast.makeText(context, message, Toast.LENGTH_SHORT).show();
	}

	public static void notify(Context context, String title, String contentTitle, String message, int id) {
		android.util.Log.v(getTag(), String.format("%s %s", contentTitle, message));

		String packageName = context.getPackageName();
		int iconId = context.getResources().getIdentifier("ic_app", "drawable", packageName);
		NotificationManager notificationManager =
				(NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
		Notification note = new Notification(iconId > 0 ? iconId : -1, title, 0);
		note.setLatestEventInfo(context, contentTitle, message, PendingIntent.getService(context, 0,
				null, 0));
		note.contentView.getLayoutId();
		notificationManager.notify(id, note);
	}


	public static void v(String message) {
		android.util.Log.v(getTag(), message);
	}

	public static void v(String message, Throwable e) {
		android.util.Log.v(getTag(), message, e);
	}

	public static void v(Context context, String message) {
		toast(context, message);
		android.util.Log.v(getTag(), message);
	}

	public static void v(Context context, String message, Throwable e) {
		toast(context, message);
		android.util.Log.v(getTag(), message, e);
	}

	public static void e(Throwable e) {
		android.util.Log.e(getTag(), "Error", e);
	}

	public static void e(String message) {
		android.util.Log.e(getTag(), message);
	}

	public static void e(String message, Throwable e) {
		android.util.Log.e(getTag(), message, e);
	}

	public static void e(Context context, String message) {
		toast(context, message);
		android.util.Log.e(getTag(), message);
	}

	public static void e(Context context, String message, Throwable e) {
		toast(context, message);
		android.util.Log.e(getTag(), message, e);
	}

	public static void w(Throwable e) {
		android.util.Log.w(getTag(), "Warning", e);
	}

	public static void w(String message) {
		android.util.Log.w(getTag(), message);
	}

	public static void w(String message, Throwable e) {
		android.util.Log.w(getTag(), message, e);
	}

	public static void w(Context context, String message) {
		toast(context, message);
		android.util.Log.w(getTag(), message);
	}

	public static void w(Context context, String message, Throwable e) {
		toast(context, message);
		android.util.Log.w(getTag(), message, e);
	}

	public static void d(String message) {
		android.util.Log.d(getTag(), message);
	}

	public static void d(String message, Throwable e) {
		android.util.Log.d(getTag(), message, e);
	}

	public static void d(Context context, String message) {
		toast(context, message);
		android.util.Log.d(getTag(), message);
	}

	public static void d(Context context, String message, Throwable e) {
		toast(context, message);
		android.util.Log.d(getTag(), message, e);
	}

	public static void i(String message) {
		android.util.Log.i(getTag(), message);
	}

	public static void i(String message, Throwable e) {
		android.util.Log.i(getTag(), message, e);
	}

	public static void i(Context context, String message) {
		toast(context, message);
		android.util.Log.i(getTag(), message);
	}

	public static void i(Context context, String message, Throwable e) {
		toast(context, message);
		android.util.Log.i(getTag(), message, e);
	}


    


}
